﻿@model QBWeb.Models.IndexViewModel
@{
    ViewBag.Title = "管理";
}

<h2>@ViewBag.Title.</h2>

<p class="text-success">@ViewBag.StatusMessage</p>
<div>
    <h4>帐户设置</h4>
    <hr />
    <dl class="dl-horizontal">
        <dt>密码:</dt>
        <dd>
            [
            @if (Model.HasPassword)
            {
                @Html.ActionLink("更改密码", "ChangePassword")
            }
            else
            {
                @Html.ActionLink("创建", "SetPassword")
            }
            ]
        </dd>
        <dt>修改昵称:</dt>
        <dd id="ModifyName">
            <span id="oldName">@ViewBag.NickName</span> 
            <input type="button" value="修改" class="btn-primary" onclick="ModifyName()"  style="width: 40px;height: 22px"/>
        </dd>
        @*<dt>外部登录名:</dt>
        <dd>
            @Model.Logins.Count [
            @Html.ActionLink("管理", "ManageLogins") ]
        </dd>*@

    </dl>
</div>

<script>
    function ModifyName() {
        const old = $(`#oldName`).text().trim();
        $(`#ModifyName`).empty();
        var text = `<input type="text" name="newName" value="${old}" style="width: 100px;height: 22px" />
                    <input type="button" value="完成" class="btn-info" onclick="CompleteName()"  style="width: 40px;height: 22px"/>`;
        $(`#ModifyName`).append(text);
    }

    function CompleteName() {
        const text = $(`input[name="newName"]`).val().trim();
        $.ajax({
            type: "POST",
            url: "/Manage/ModifyName",
            data: { newName: text },
            dataType: "text",
            success: function (data) {
                layer.msg("修改成功");
                $(`#ModifyName`).empty();
                var htmlText = ` <span id="oldName">${text}</span>
                                <input type="button" value="修改" class="btn-primary" onclick="ModifyName()"  style="width: 40px;height: 22px"/>`;
                $(`#ModifyName`).append(htmlText);
            },error:function() {
                layer.msg("修改失败");
            }
        });
    }
</script>
@*
    电话号码可以用作双因素身份验证系统中的第二个验证因素。

     要详细了解如何设置此 ASP.NET 应用程序以支持使用
        SMS 进行双因素身份验证，请参阅<a href="https://go.microsoft.com/fwlink/?LinkId=403804">此文章</a>。

     设置双因素身份验证后，取消注释以下块
*@
@*
    <dt>电话号码:</dt>
    <dd>
        @(Model.PhoneNumber ?? "None")
        @if (Model.PhoneNumber != null)
        {
            <br />
            <text>[&nbsp;&nbsp;@Html.ActionLink("Change", "AddPhoneNumber")&nbsp;&nbsp;]</text>
            using (Html.BeginForm("RemovePhoneNumber", "Manage", FormMethod.Post, new { @class = "form-horizontal", role = "form" }))
            {
                @Html.AntiForgeryToken()
                <text>[<input type="submit" value="删除" class="btn-link" />]</text>
            }
        }
        else
        {
            <text>[&nbsp;&nbsp;@Html.ActionLink("Add", "AddPhoneNumber")
        }
    </dd>
*@
<!--<dt>双重身份验证:</dt>
<dd>
    <p>
        未配置双因素身份验证提供程序。请参阅<a href="https://go.microsoft.com/fwlink/?LinkId=403804">此文章</a>
        详细了解如何设置此 ASP.NET 应用程序以支持双因素身份验证。
    </p>-->
@*@if (Model.TwoFactor)
    {
        using (Html.BeginForm("DisableTwoFactorAuthentication", "Manage", FormMethod.Post, new { @class = "form-horizontal", role = "form" }))
        {
            @Html.AntiForgeryToken()
            <text>已启用
            <input type="submit" value="禁用" class="btn btn-link" />
            </text>
        }
    }
    else
    {
        using (Html.BeginForm("EnableTwoFactorAuthentication", "Manage", FormMethod.Post, new { @class = "form-horizontal", role = "form" }))
        {
            @Html.AntiForgeryToken()
            <text>已禁用
            <input type="submit" value="启用" class="btn btn-link" />
            </text>
        }
    }*@
<!--</dd>-->